/*
   \file  file_utils.cc
   \brief Definitions of functions defined in file_utils.hh.
*/

/*
   This file is part of libgist.

   libgist is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2 of the License, or (at your
   option) any later version.

   libgist is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
   for more details.

   You should have received a copy of the GNU General Public License
   along with libgist; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/

/*
   REVISION HISTORY

   $HeadURL: http://libgist.googlecode.com/svn/branches/lazebnik_dev/drv/file_utils.cc $
   $Id: file_utils.cc 42 2011-08-22 10:51:07Z libgist@gmail.com $
*/

//-------------------------- BOOST-BASED API ----------------------------

#ifdef GISTDRV_HAVE_BOOST_FILESYSTEM

// gist headers
#include "file_utils.hh"

// Boost headers
#include <boost/filesystem/operations.hpp>

namespace gistdrv {

// File/path name tests
bool exists(const std::string& path)
{
   namespace fs = boost::filesystem ;
   return fs::exists(fs::path(path));
}

} // end of namespace encapsulating above definitions

#else // Boost.Filesystem not available

//-------------------------- UNIX-BASED API -----------------------------

// gist headers
#include "file_utils.hh"

// Unix headers
#include <sys/stat.h>
#include <sys/types.h>

namespace gistdrv {

// File/path name tests
bool exists(const std::string& path)
{
   struct stat buf ;
   return stat(path.c_str(), &buf) == 0 ;
}

} // end of namespace encapsulating above functions

#endif // GISTDRV_HAVE_BOOST_FILESYSTEM

//-----------------------------------------------------------------------

/* So things look consistent in everyone's emacs... */
/* Local Variables: */
/* indent-tabs-mode: nil */
/* End: */
